package com.zhf.app;

import com.zhf.dao.UserDao;
import com.zhf.entity.User;
import com.zhf.utils.DateUtils;
import com.zhf.utils.UUIDUtils;
import org.junit.Test;

import java.sql.SQLException;

/**
 * @Author: ZhaoHuanfeng
 * @Date: 2020/9/27 15:22
 */
public class TestUserDao {
    UserDao userDao=new UserDao();

    //测试注册用户
    @Test
    public void testRegister() throws SQLException {

        //创建user
        User user=new User();
        user.setUid(UUIDUtils.getUUID());
        user.setUsername("武松");
        user.setPassword("123456");
        user.setPassword("123456");
        user.setTelephone("13512341234");
        user.setSex("男");
        user.setBirthday(DateUtils.getDateFormart());

        //执行注册
        int register = userDao.register(user);
        if (register>0){
            System.out.println("注册成功！");
        }else {
            System.out.println("注册失败");
        }
    }

    //测试用户登录
    @Test
    public void testLogin() throws SQLException {
        //调用UserDao的login方法 传入用户名和密码
        User user=userDao.login("武松","123456");

        //处理结果
        if (user!=null){
            System.out.println("登录成功");
        }else {
            System.out.println("用户名或密码错误");
        }
    }
}
